// 获取第一份数据
$.get(url1,(data1) =>{
    console.log(data1);
    // 获取第二份数据
    $.get(url2+data1.id,(data2) =>{
        console.log(data2)
        //获取第三份数据
        $.get(url3+data2.id,(data3)=>{
            console.log(data3);
        },)
    })
})


function getData(url) {
    return new Promise((resolve,reject) => {
        $.ajax({
            url,
            success(data){
                resolve(data)
            },
            error(err){
                reject(err)
            }
        })
    })
}

getData(url1).then(data1=>{
    console.log(data1);
    return getData(url2+data1.id)
}).then(data2=>{
    console.log(data2);
    return getData(url3+data2.id)
}).then(data3 =>{
    console.log(data3)
}).catch(err => console.log(err))



async function getData3(){
    const data1 = await getData(url1)
    const data2 = await getData(url2+data1.id)
    const data3 = await getData(url3+data2.id)
    console.log(data3);
}

setTimeout(() => {
    console.log('22222')
}, 100);


function newPromise(url){
    return new Promise((resolve, reject) => {
        const img = new Image();
        img.onload = function() {
        console.log("一张图片加载完成");
        resolve(img);
        };
        img.onerror = function() {
            reject(new Error('Could not load image at' + url));
        };
        img.src = url;
    })
}